import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long num = scanner.nextLong();
        long tmp = 1;
        long min = 2100000000;
        while(num / tmp != 0) {
            long ret1 = num / tmp;
            long ret2 = num % tmp;
            if(ret1 + ret2 < min) {
                min = ret1 + ret2;
            }
            tmp = tmp * 10;
        }
        System.out.println(min);
    }

}
